package cn.skycity.common.service.impl;

import cn.skycity.common.mapper.SysDictDataMapper;
import cn.skycity.common.mapper.SysDictTypeMapper;
import cn.skycity.common.service.ISysDictTypeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skycity.framework.uaa.pojo.entity.SysDictData;
import com.skycity.framework.uaa.pojo.entity.SysDictType;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author YingBo.Dai
 * @since 2024-12-13
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService {
    @Resource
    private SysDictDataMapper sysDictDataMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteByCode(long id) {
        SysDictType sysDictType = baseMapper.selectById(id);
        sysDictDataMapper.delete(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, sysDictType.getDictType()));
        baseMapper.delete(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getId, id));
    }

}
